Skip to content

[fix](iceberg) Harden external-write lifecycle, OCC, memory, and file ownership - #66348

Open
Gabriel39 wants to merge 24 commits into
apache:masterfrom
Gabriel39:fix/iceberg-write-safety
Open

[fix](iceberg) Harden external-write lifecycle, OCC, memory, and file ownership#66348
Gabriel39 wants to merge 24 commits into
apache:masterfrom
Gabriel39:fix/iceberg-write-safety

Conversation

@Gabriel39

@Gabriel39 Gabriel39 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary:

Iceberg and Hive external writes had correctness and resource-safety gaps across statement lifecycle, optimistic concurrency, asynchronous memory ownership, multipart publication, final-report ownership transfer, and orphan cleanup.

This PR:

  • brings pre-execution failures into the normal rollback scope while keeping post-commit refresh and listener failures from turning a durable external commit into a retryable statement failure;
  • binds row-level DML and overwrite writes to the exact read snapshot and branch, including the empty-table generation across transaction refresh, and validates concurrent changes before commit;
  • transfers asynchronous reservations with queued blocks, releases every reservation on terminal writer paths, accounts for all partition sorters using safe row/byte bounds from the actual incoming block, reserves cold partition dispatch and final spill-merge workspace, and saturates reservation arithmetic instead of allowing overflow;
  • propagates partition-writer close failures, aborts incomplete multipart uploads, uses compact row permutations for partition dispatch, and preserves configurable Iceberg metrics behavior;
  • emits Hive, Iceberg, and MaxCompute ownership vectors only in the final report, validates that complete report against the smaller FE/BE Thrift limit, and transfers ownership only after coordinator acceptance;
  • retains provider cleanup callbacks for deferred Hive uploads until final acknowledgement, aborts them on definite rejection, preserves them on ambiguous transports, and self-rolls back Hive validation or classification failures;
  • gates Iceberg table and standalone DELETE file production on coordinator report-ack support before file creation;
  • publishes Azure multipart data atomically with exact staged block IDs and target leases, and fails closed without reacquiring a lease after the upload-generation fence is lost;
  • implements remove_orphan_files with retained-snapshot reachability, explicit retention and safety limits, deduplicated scans, and fail-closed ownership for shared external roots unless an explicit verified location is supplied.

Release note

Harden Iceberg and Hive external-write lifecycle, OCC conflict detection, memory admission, multipart publication, final-report ownership transfer, and orphan-file safety.

Testing

  • HiveConnectorTransactionTest: 17 passed, including validation/classification self-rollback and malformed-record isolation.

  • Iceberg connector focused suites: 295 passed after rebasing onto the latest Iceberg V3 changes.

  • Azure filesystem extension suite: 26 passed.

  • FE report acknowledgement, task-state, sink-binding, and insert-executor focused suites: 30 passed.

  • Rebased BE ASAN focused suites: 13 passed, covering final-only report ownership, deferred S3 cleanup, standalone DELETE ACK gating, active writer snapshots, and the upstream missing-partition-source validation.

  • External-file report lifecycle verification: 8/8 ASAN tests passed, covering successful Hive close, periodic metadata deferral, exact final pending-upload identity, and provider abort on definite final-report rejection.

  • Sorted-write admission and ownership verification: 29/29 ASAN tests passed, covering multi-partition row/byte bounds, cold writer dispatch, reservation overflow, async write/EOS transfer, terminal cleanup, real spill fan-in, real 128-partition selection, and Azure final-report rejection.

  • All pre-existing branch commits remained patch-equivalent after rebasing onto master.

  • Header self-containment compile verification: all four affected ANN translation units, RuntimeState, and PipelineFragmentContext passed ASAN syntax-only compilation after adding the missing Thrift forward declaration.

  • All changed BE C/C++ files passed the repository clang-format v16 check; the latest 12-file update also passed clang-format v16 dry-run and git diff --check.

  • FE Checkstyle completed with 0 violations.

  • Connector forbidden-import architecture gate passed.

  • Focused clang-tidy found and fixed the changed sorter warning; full translation-unit analysis remains blocked by repository-baseline unconditional static assertions in be/src/util/jni-util.h.

  • Regression framework MTMV job lookup: the targeted test failed with the old cross-MV status query and passed with the isolated jobs metadata query; all 4 framework tests passed, with Java and Groovy compilation successful.

  • Iceberg merge sink BE UT: reproduced 12/14 failures with a mock coordinator missing report-ACK capability; after modeling an ACK-capable coordinator, all 14 merge sink tests passed, and the separate no-ACK fail-closed test also passed (15/15 focused ASAN tests).

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes. External writes now fail closed on concurrency, protocol, report-size, lease-generation, and ownership uncertainty; durable commits are not retried because of post-commit refresh failures; Iceberg sorted-write admission is bounded by the actual input while preserving cumulative growth safety.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: the static review found nine actionable issues (six P1, three P2), including three paths that can delete or reference missing Iceberg data, a concurrent use-after-free, an aggregate Thrift limit bypass, pathological spill reservation, and two incomplete object-storage cleanup paths.

Critical checkpoint conclusions:

  1. Goal and proof: The PR partially hardens write/cleanup/OCC behavior, and the overwrite and external-insert lifecycle changes are credible, but the nine inline findings prevent the stated lifecycle and cleanup goals from being met. Added tests prove only narrow single-state, AWS-abort, permutation, and executor cases.
  2. Scope and clarity: The edits are generally focused, but the new destructive action reimplements Iceberg safety policy incompletely, and the provider-neutral abort surface is implemented with AWS-specific state.
  3. Concurrency: The async writer publishes active-writer snapshots while a separately scheduled revocation task reads them. Per-writer _sorter_mutex locking is consistent and no deadlock was found, but it cannot protect the snapshot container because the range-for drops its temporary owner before iteration (MAIN-BE-003).
  4. Lifecycle: Sort-writer close/cancel/deferred cleanup and external commit/listener ordering were traced end to end and otherwise preserve error ownership. S3/Azure abort lifecycle is incomplete: a rejected abort is never retried, and Azure reports successful abandonment without provider cleanup (MAIN-IO-001/002).
  5. Configuration: No new configuration was added. Existing thrift_max_message_size and S3 limiter settings are read dynamically, but their consumers do not enforce the correct aggregate/cleanup contracts.
  6. Compatibility: No storage-format or wire-field change was introduced. Default virtual methods preserve source-level parallel implementations, but that default is exactly why Azure silently lacks the new cleanup behavior.
  7. Parallel paths: Static/dynamic/branch/empty overwrites, data/delete writers, sync/async/destructor close, S3/Azure providers, and all insert executors were checked. The accepted findings identify the paths where parity is missing.
  8. Conditional checks: Existing overwrite conflict conditions are sound. The orphan action is missing the required gc.enabled fence, safe retention interval, canonical URI identity handling, and version-hint reachability.
  9. Test coverage: Coverage is not comprehensive. Missing cases include multi-task aggregate reports, concurrent snapshot publication/traversal, many-partition reserve accounting, hard-limit abort rejection, Azure staged-block abort, and execution-level orphan deletion tests for GC, retention, URI aliases, and the version hint.
  10. Test results: The new assertions are logically consistent within their narrow scopes; no result files changed. Builds and tests were intentionally not run because the authoritative review prompt forbids them, so this conclusion is static-only.
  11. Observability: Existing timers/logs cover writer/spill/commit paths, and abort failures are warned. No additional standalone observability defect was found, but logging does not substitute for retained cleanup ownership or retry.
  12. Transaction and persistence: No Doris EditLog state is added. Iceberg overwrite OCC anchors for main/branch/empty/static/dynamic cases are sound, and the durable external commit marker precedes refresh/listener suppression. The orphan action can nevertheless race a concurrent external commit (MAIN-FE-004).
  13. Data writes and atomicity: The aggregate-report failure can strand uncommitted objects; unsafe orphan deletion can corrupt shared, aliased, or concurrent writes; and multipart cleanup can leak provider state. These are blocking write-lifecycle defects.
  14. FE/BE propagation: No new FE-BE variable or Thrift field is introduced. Existing commit metadata is propagated on every producer path, but its budget is enforced per task rather than on the final aggregated RPC (MAIN-BE-001).
  15. Performance: Compact permutation dispatch is semantically sound, and bounded snapshot-copy cost is not independently material. Summing one full-batch reserve estimate per active partition can request roughly 128 blocks and repeatedly spill tiny partitions (MAIN-BE-002).
  16. Other issues: Error precedence, close idempotence, spill cleanup, overwrite validation, permission checks, location containment, and post-commit listener behavior produced no additional substantiated defects.

User focus: review_focus.txt contained no additional focus guidance, so the whole PR was reviewed without a narrower focus.

Review status: complete and converged in round 3. All final full-scope and risk-focused reviewers returned NO_NEW_VALUABLE_FINDINGS for this exact comment set. Static review only; no builds or tests were run.

Comment thread be/src/exec/pipeline/pipeline_fragment_context.cpp Outdated
Comment thread be/src/exec/operator/spill_iceberg_table_sink_operator.cpp Outdated
Comment thread be/src/exec/operator/spill_iceberg_table_sink_operator.cpp Outdated
Comment thread be/src/io/fs/rate_limited_obj_storage_client.cpp Outdated
Comment thread be/src/io/fs/s3_file_writer.cpp
@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 18.75% (3/16) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29107 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 6ebd31859839dabd9ae88df95c3c1834ed99d722, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17724	4095	4036	4036
q2	2006	335	200	200
q3	10328	1369	813	813
q4	4688	483	343	343
q5	7525	844	555	555
q6	187	170	136	136
q7	771	784	599	599
q8	9346	1605	1623	1605
q9	5334	4112	4083	4083
q10	6769	1631	1355	1355
q11	501	357	331	331
q12	709	575	454	454
q13	18114	3320	2756	2756
q14	260	262	247	247
q15	q16	748	732	654	654
q17	928	919	987	919
q18	6906	5853	5666	5666
q19	1360	1268	1053	1053
q20	808	657	605	605
q21	6000	2578	2390	2390
q22	447	364	307	307
Total cold run time: 101459 ms
Total hot run time: 29107 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4319	4280	4276	4276
q2	297	314	215	215
q3	4535	4912	4383	4383
q4	2217	2258	1414	1414
q5	4276	4138	4121	4121
q6	231	176	130	130
q7	1706	1595	1391	1391
q8	2231	1955	1892	1892
q9	6827	6773	6754	6754
q10	4263	4253	3830	3830
q11	524	388	404	388
q12	715	711	510	510
q13	2979	3259	2765	2765
q14	292	304	261	261
q15	q16	670	693	607	607
q17	1268	1234	1237	1234
q18	7298	7009	6779	6779
q19	1072	1049	1074	1049
q20	2214	2232	1943	1943
q21	5323	4580	4471	4471
q22	524	469	423	423
Total cold run time: 53781 ms
Total hot run time: 48836 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 169793 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 6ebd31859839dabd9ae88df95c3c1834ed99d722, data reload: false

query5	3980	613	479	479
query6	476	231	217	217
query7	4824	562	336	336
query8	325	179	163	163
query9	8513	4033	4021	4021
query10	454	357	299	299
query11	5709	2212	1980	1980
query12	150	100	99	99
query13	1266	608	412	412
query14	5318	4673	4396	4396
query14_1	3834	3792	3774	3774
query15	201	193	182	182
query16	1031	490	457	457
query17	868	679	542	542
query18	2574	470	345	345
query19	205	194	156	156
query20	104	107	106	106
query21	175	161	134	134
query22	13035	12884	12868	12868
query23	17358	16425	16089	16089
query23_1	16147	16100	16089	16089
query24	7499	1666	1250	1250
query24_1	1249	1255	1238	1238
query25	565	457	387	387
query26	1228	360	215	215
query27	2592	634	373	373
query28	4442	2056	2026	2026
query29	1125	631	496	496
query30	348	267	226	226
query31	1134	1082	950	950
query32	120	64	60	60
query33	565	326	248	248
query34	1178	1116	599	599
query35	735	744	637	637
query36	798	780	686	686
query37	158	112	96	96
query38	1867	1659	1609	1609
query39	824	830	825	825
query39_1	770	783	787	783
query40	249	163	153	153
query41	69	70	71	70
query42	96	95	94	94
query43	314	323	273	273
query44	1405	760	768	760
query45	201	175	171	171
query46	1045	1189	718	718
query47	1551	1539	1399	1399
query48	394	419	302	302
query49	591	418	305	305
query50	1033	450	344	344
query51	10626	10576	10510	10510
query52	86	89	77	77
query53	272	281	202	202
query54	288	249	244	244
query55	78	73	70	70
query56	322	322	317	317
query57	1010	1003	923	923
query58	316	259	254	254
query59	1506	1604	1352	1352
query60	341	269	255	255
query61	146	152	150	150
query62	396	318	264	264
query63	242	196	198	196
query64	2828	1033	855	855
query65	3868	3841	3860	3841
query66	1802	471	355	355
query67	28286	28254	28153	28153
query68	3061	1582	1060	1060
query69	405	311	273	273
query70	898	787	811	787
query71	379	330	308	308
query72	3025	2617	2290	2290
query73	853	856	415	415
query74	4591	4485	4297	4297
query75	2345	2356	1997	1997
query76	2335	1112	746	746
query77	329	361	276	276
query78	11206	11081	10586	10586
query79	1392	1191	741	741
query80	1270	541	454	454
query81	559	322	283	283
query82	563	148	116	116
query83	425	320	292	292
query84	322	157	129	129
query85	1011	607	529	529
query86	430	227	224	224
query87	1806	1795	1693	1693
query88	3690	2833	2795	2795
query89	399	315	289	289
query90	1781	200	187	187
query91	198	190	159	159
query92	66	61	59	59
query93	1720	1542	943	943
query94	711	346	310	310
query95	769	491	487	487
query96	1039	777	347	347
query97	2447	2443	2335	2335
query98	208	197	189	189
query99	719	718	611	611
Total cold run time: 249432 ms
Total hot run time: 169793 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 23.92 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 6ebd31859839dabd9ae88df95c3c1834ed99d722, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.05	0.06
query3	0.25	0.13	0.13
query4	1.61	0.14	0.14
query5	0.24	0.22	0.23
query6	1.16	0.84	0.81
query7	0.04	0.01	0.00
query8	0.06	0.04	0.04
query9	0.38	0.32	0.32
query10	0.58	0.59	0.58
query11	0.19	0.13	0.13
query12	0.18	0.15	0.15
query13	0.45	0.48	0.48
query14	1.01	1.00	1.00
query15	0.59	0.59	0.58
query16	0.30	0.34	0.31
query17	1.11	1.12	1.14
query18	0.21	0.19	0.20
query19	2.05	1.89	1.96
query20	0.02	0.02	0.01
query21	15.42	0.21	0.13
query22	4.89	0.05	0.06
query23	16.12	0.31	0.13
query24	2.91	0.43	0.32
query25	0.11	0.05	0.05
query26	0.71	0.20	0.14
query27	0.04	0.03	0.03
query28	3.52	0.79	0.32
query29	12.49	4.03	3.20
query30	0.27	0.16	0.15
query31	2.76	0.55	0.32
query32	3.23	0.58	0.49
query33	3.20	3.26	3.14
query34	15.57	4.13	3.29
query35	3.25	3.20	3.22
query36	0.55	0.44	0.45
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.14	0.15
query41	0.07	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 96.07 s
Total hot run time: 23.92 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 40.29% (83/206) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 59.17% (25636/43323)
Line Coverage 43.24% (257196/594852)
Region Coverage 38.91% (203842/523919)
Branch Coverage 40.27% (93046/231076)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 68.45% (141/206) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.68% (31980/42255)
Line Coverage 60.31% (356346/590877)
Region Coverage 56.86% (298902/525687)
Branch Coverage 58.28% (134698/231114)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 18.75% (3/16) 🎉
Increment coverage report
Complete coverage report

Gabriel39 added a commit to Gabriel39/incubator-doris that referenced this pull request Aug 1, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66348

Problem Summary: Parallel Iceberg sink tasks could exceed the shared report limit, partition writers could over-reserve memory or outlive a temporary snapshot, failed multipart uploads could skip mandatory cleanup, and orphan-file deletion lacked Iceberg safety fences. Share the report budget, retain writer snapshots, bound reservations, make abort cleanup provider-aware, and enforce safe canonical orphan detection.

### Release note

Improve Iceberg write failure cleanup and orphan-file deletion safety.

### Check List (For Author)

- Test: Unit Test
    - BE ASAN focused tests with Azure support enabled
    - Full fe-connector-iceberg unit test suite
- Behavior changed: Yes, unsafe orphan cutoffs and GC-disabled deletion are rejected, and failed multipart uploads are cleaned up reliably.
- Does this need documentation: No
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: two distinct issues remain after the current fixes: Azure abort can delete a valid pre-existing Put Blob object, and orphan-file reachability repeatedly scans inherited manifests with quadratic cost. I did not duplicate the existing review threads.

Critical checkpoint conclusions:

  • Goal and proof: The PR broadly hardens Iceberg write/cleanup lifecycle, OCC, reporting limits, and orphan cleanup, but the Azure data-preservation goal is not yet met. The added tests cover nominal cleanup and OCC paths, not the two cases below.
  • Scope and clarity: The changes are cohesive for the stated lifecycle work. The orphan action's hand-built reachability scan is the one area that should reuse Iceberg's unique-manifest approach.
  • Concurrency: Async writer publication is protected by retained shared snapshots and per-sorter locking; the shared report budget has a consistent lock order. Azure's committed-block test is not a valid ownership fence for an existing object.
  • Lifecycle: FE before-execution cleanup and post-commit error boundaries are sound, as are the reviewed nested writer close paths. Azure abort still destroys state it does not own.
  • Configuration: No new configuration behavior requires dynamic-reload handling.
  • Compatibility: No FE-BE or storage-format incompatibility was found. The changed Azure block-ID format has a bounded retry impact and did not survive as a separate finding.
  • Parallel paths: S3, Azure, single-shot, multipart, committer, overwrite, branch, static/dynamic overwrite, and delete/merge paths were traced; the surviving provider-specific issue is inline.
  • Conditional checks: GC, retention, URI containment, identity ambiguity, and overwrite validation checks are fail-closed. CommittedBlocks.empty() is the invalid special case.
  • Test coverage: Unit coverage is substantial but misses preservation of an existing Put Blob target and an append-heavy multi-snapshot reachability scan. No end-to-end result covers either.
  • Test results: No tests or builds were run because the authoritative review task is static-only; no generated result files were changed.
  • Observability: Existing status/log paths are adequate for the reviewed failures; no additional metric was required for a correctness conclusion.
  • Transactions and persistence: Iceberg overwrite OCC, including empty-table and branch anchors, is sound. No EditLog or master-failover persistence change is involved.
  • Data writes: Commit/report cleanup ownership is sound outside the Azure abort branch; that branch can lose previously committed data and blocks approval.
  • FE-BE variables: No new cross-version transmitted variable or missing propagation path was found.
  • Performance: Per-snapshot planFiles() causes the P2 quadratic manifest-read issue below; no other distinct hot-path issue survived duplicate suppression.
  • Other issues: The sorter aggregate-reservation concern remains covered by the existing thread, and cleanup admission/terminal-state concerns remain covered by the existing Azure/rate-limit threads, so they are not repeated here.

User focus: no additional user-provided focus was present; the full PR was reviewed.

Comment thread be/src/io/fs/azure_obj_storage_client.cpp Outdated
@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 18.75% (3/16) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29004 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 1241244cc139a902b16c5f3ce1fea1335d4fa123, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17734	4014	4200	4014
q2	2025	322	212	212
q3	10260	1426	849	849
q4	4715	473	338	338
q5	7659	840	558	558
q6	196	174	137	137
q7	733	813	590	590
q8	10415	1459	1590	1459
q9	5582	4080	4036	4036
q10	6807	1625	1362	1362
q11	527	346	342	342
q12	753	565	458	458
q13	18112	3337	2794	2794
q14	264	259	245	245
q15	q16	736	740	663	663
q17	1027	977	1049	977
q18	6986	5815	5492	5492
q19	1191	1315	1054	1054
q20	771	684	599	599
q21	5794	2661	2529	2529
q22	442	357	296	296
Total cold run time: 102729 ms
Total hot run time: 29004 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4429	4359	4262	4262
q2	281	319	211	211
q3	4560	4972	4362	4362
q4	2164	2256	1413	1413
q5	4304	4144	4124	4124
q6	229	176	129	129
q7	1695	1888	1731	1731
q8	2500	2078	2109	2078
q9	7351	7231	7252	7231
q10	4323	4277	3878	3878
q11	568	416	395	395
q12	739	749	509	509
q13	3253	3703	2962	2962
q14	317	307	276	276
q15	q16	726	738	647	647
q17	1372	1331	1262	1262
q18	7878	7307	7282	7282
q19	1099	1082	1087	1082
q20	2193	2208	1921	1921
q21	5323	4643	4500	4500
q22	534	454	406	406
Total cold run time: 55838 ms
Total hot run time: 50661 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 169560 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 1241244cc139a902b16c5f3ce1fea1335d4fa123, data reload: false

query5	4327	615	455	455
query6	475	228	202	202
query7	4911	575	348	348
query8	333	196	168	168
query9	8769	4044	4075	4044
query10	457	337	296	296
query11	5849	2196	2002	2002
query12	154	97	95	95
query13	1288	553	438	438
query14	6095	4702	4367	4367
query14_1	3857	3809	3803	3803
query15	215	204	179	179
query16	1011	475	466	466
query17	1133	738	541	541
query18	2438	460	331	331
query19	204	178	137	137
query20	108	100	98	98
query21	231	151	134	134
query22	13039	13083	12822	12822
query23	17152	16281	15998	15998
query23_1	16123	16080	16068	16068
query24	7462	1684	1224	1224
query24_1	1262	1261	1279	1261
query25	520	424	341	341
query26	1326	372	214	214
query27	2595	603	374	374
query28	4468	2023	2030	2023
query29	1022	586	464	464
query30	350	261	221	221
query31	1102	1069	935	935
query32	99	62	58	58
query33	512	307	241	241
query34	1166	1178	660	660
query35	751	748	641	641
query36	782	782	706	706
query37	153	105	95	95
query38	1833	1639	1612	1612
query39	812	808	797	797
query39_1	789	781	780	780
query40	247	163	142	142
query41	65	62	64	62
query42	101	94	93	93
query43	318	321	284	284
query44	1411	775	754	754
query45	184	169	169	169
query46	1024	1162	738	738
query47	1522	1508	1411	1411
query48	397	407	300	300
query49	588	403	294	294
query50	1010	418	329	329
query51	10784	10644	10642	10642
query52	87	94	76	76
query53	264	279	210	210
query54	301	257	236	236
query55	80	73	69	69
query56	319	316	302	302
query57	1004	997	921	921
query58	286	253	277	253
query59	1534	1600	1462	1462
query60	338	282	261	261
query61	175	167	169	167
query62	406	325	266	266
query63	232	203	205	203
query64	2932	1141	966	966
query65	3944	3830	3838	3830
query66	1828	497	376	376
query67	28341	28181	28062	28062
query68	3469	1491	926	926
query69	414	301	289	289
query70	911	821	799	799
query71	370	337	315	315
query72	3037	2617	2311	2311
query73	794	795	435	435
query74	4631	4474	4295	4295
query75	2392	2344	1999	1999
query76	2323	1150	724	724
query77	339	381	279	279
query78	11169	11189	10572	10572
query79	1364	1154	760	760
query80	1269	550	456	456
query81	517	327	280	280
query82	622	150	116	116
query83	365	320	298	298
query84	272	160	128	128
query85	970	599	524	524
query86	405	226	209	209
query87	1786	1801	1724	1724
query88	3737	2818	2788	2788
query89	395	317	289	289
query90	1893	201	200	200
query91	204	188	161	161
query92	60	61	56	56
query93	1663	1525	1002	1002
query94	719	368	314	314
query95	792	509	468	468
query96	1114	810	360	360
query97	2455	2457	2313	2313
query98	214	195	190	190
query99	724	723	612	612
Total cold run time: 256498 ms
Total hot run time: 169560 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 23.98 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 1241244cc139a902b16c5f3ce1fea1335d4fa123, data reload: false

query1	0.01	0.00	0.01
query2	0.10	0.05	0.04
query3	0.26	0.14	0.13
query4	1.61	0.14	0.14
query5	0.24	0.23	0.22
query6	1.16	0.83	0.83
query7	0.03	0.01	0.01
query8	0.06	0.04	0.04
query9	0.39	0.32	0.33
query10	0.59	0.54	0.56
query11	0.19	0.14	0.14
query12	0.18	0.14	0.14
query13	0.47	0.46	0.46
query14	1.00	1.00	0.99
query15	0.60	0.59	0.58
query16	0.31	0.32	0.33
query17	1.07	1.08	1.08
query18	0.22	0.20	0.20
query19	2.03	2.01	1.95
query20	0.03	0.01	0.02
query21	15.46	0.24	0.13
query22	4.77	0.06	0.05
query23	16.12	0.31	0.12
query24	2.95	0.42	0.33
query25	0.11	0.06	0.04
query26	0.72	0.20	0.16
query27	0.05	0.03	0.04
query28	3.55	0.77	0.35
query29	12.47	4.07	3.19
query30	0.27	0.16	0.16
query31	2.78	0.54	0.31
query32	3.23	0.58	0.49
query33	3.22	3.16	3.26
query34	15.58	3.94	3.28
query35	3.24	3.23	3.24
query36	0.56	0.45	0.43
query37	0.10	0.06	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.17	0.16
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.15 s
Total hot run time: 23.98 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 36.68% (95/259) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 59.18% (25642/43332)
Line Coverage 43.24% (257265/594944)
Region Coverage 38.93% (203959/523957)
Branch Coverage 40.27% (93050/231088)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 59.46% (154/259) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.80% (32034/42263)
Line Coverage 60.46% (357286/590968)
Region Coverage 57.19% (300637/525724)
Branch Coverage 58.55% (135316/231126)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 18.75% (3/16) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: None

Related PR: apache#66348

Problem Summary: Parallel Iceberg sink tasks could exceed the shared report limit, partition writers could over-reserve memory or outlive a temporary snapshot, failed multipart uploads could skip mandatory cleanup, and orphan-file deletion lacked Iceberg safety fences. Share the report budget, retain writer snapshots, bound reservations, make abort cleanup provider-aware, and enforce safe canonical orphan detection.

### Release note

Improve Iceberg write failure cleanup and orphan-file deletion safety.

### Check List (For Author)

- Test: Unit Test
    - BE ASAN focused tests with Azure support enabled
    - Full fe-connector-iceberg unit test suite
- Behavior changed: Yes, unsafe orphan cutoffs and GC-disabled deletion are rejected, and failed multipart uploads are cleaned up reliably.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66348

Problem Summary: Azure abort could delete a pre-existing Put Blob object because an empty committed block list does not mean the key has no committed content. Iceberg orphan cleanup also reopened inherited data manifests once per retained snapshot, making long histories quadratic. Preserve Put Blob content while discarding only staged block-list replacements, and scan each unique retained manifest once.

### Release note

Preserve existing Azure objects during failed Iceberg replacements and bound orphan cleanup manifest reads.

### Check List (For Author)

- Test: Unit Test
    - Azure abort helper BE unit test
    - Iceberg orphan action FE unit tests
- Behavior changed: Yes, Azure abort no longer deletes pre-existing Put Blob content and orphan cleanup deduplicates manifest reads.
- Does this need documentation: No
Issue Number: None

Related PR: apache#66348

Problem Summary: The latest review found that async memory admission ended before queued writes, Azure temporary-copy publication and its compatibility mirror were unsafe for same-key writers, BE did not know FE smaller Thrift limit, branch writes could lose the exact MVCC pin, and orphan cleanup assumed ownership for layouts it could not prove. Transfer reservations across the async queue, publish Azure block lists atomically on the target, negotiate the receiver limit, bind branch-aware pins after the target branch is known, and use ownership-aware bounded orphan scans.

Harden Iceberg async write admission, Azure multipart publication, and orphan-file cleanup safety.

- Test: Unit Test
  - BE targeted unit tests: 7 passed.
  - FE targeted unit tests: 37 passed; all 59 reactor modules built successfully.
  - Azure-enabled production and test translation units compiled successfully.
- Behavior changed: Yes. Unsafe orphan scan roots now require an explicit guarded override, and conflicting Azure same-key multipart writers fail closed instead of mixing data.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66348

Problem Summary: A standalone Iceberg DELETE bypassed the table-writer capability gate, so a new BE could create delete files for an old coordinator that cannot acknowledge ownership transfer. Share the report-acknowledgement validation across table and delete writers and reject the direct delete path before it can create files.

### Release note

Prevent standalone Iceberg deletes from creating files when the coordinator cannot acknowledge external-file ownership transfer.

### Check List (For Author)

- Test: Unit Test
    - VIcebergDeleteSinkTest.*
    - VIcebergTableWriterTest.RejectsCoordinatorWithoutExternalFileReportAck
- Behavior changed: Yes. Mixed-version standalone Iceberg DELETE now fails before file creation when the coordinator lacks report acknowledgement support.
- Does this need documentation: No
Issue Number: None

Related PR: apache#66348

Problem Summary: Periodic reports could prematurely send external commit vectors, while final-report rejection and Hive pre-commit failures could lose the last cleanup owner for deferred object-store uploads. Keep ownership-bearing vectors final-only, retain provider cleanup callbacks until the final report is accepted, and self-rollback Hive validation or classification failures. Also align the orphan-action imports with the connector SPI package.

None

- Test: Unit Test

    - HiveConnectorTransactionTest: 17 tests passed

    - Iceberg connector focused suites: 283 tests passed

    - Azure object-storage extension suite: 26 tests passed

    - FE core focused suites: 30 tests passed

    - Changed BE production and unit-test objects compiled successfully

    - clang-format v16 and connector import gate passed

- Behavior changed: Yes, external-write ownership is transferred only by an accepted final report

- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66348

Problem Summary: The external-file report tests covered periodic metadata suppression and deferred provider cleanup separately, but did not exercise their ownership handoff as one lifecycle. Add a Hive writer regression that verifies a successful close retains the exact pending upload, periodic reports omit it, final reports include it, and a definite coordinator rejection aborts the retained provider upload.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - VHivePartitionWriterReportLifecycleTest.*
    - RuntimeStateIcebergCommitDataTest.*
    - S3FileWriterTest.failedReportCleanupAbortsDeferredProviderUploadAfterClose
    - 8 focused ASAN BE tests passed
    - clang-format v16 check passed
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66348

Problem Summary: runtime_state.h exposed a pointer to TReportExecStatusParams without declaring the generated Thrift class. Translation units that included RuntimeState without FrontendService types failed the full BE build. Forward-declare the pointer-only type so the header is self-contained without importing the full frontend service header.

### Release note

None

### Check List (For Author)

- Test: Manual test
    - Reproduced the failing ANN translation-unit compile before the fix.
    - All four affected ANN translation units passed ASAN syntax-only compilation after the fix.
    - RuntimeState and PipelineFragmentContext translation units passed ASAN syntax-only compilation.
    - clang-format v16 check passed for the affected header.
    - Full local BE build and focused BE UT were attempted but blocked before source compilation by an incomplete external Arrow thirdparty installation.
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66348

Problem Summary: Iceberg sorted writes could either sum a full batch estimate for every active partition or under-account cold partition dispatch and near-capacity sorter growth. The existing regressions also tested several ownership helpers in isolation instead of exercising the asynchronous writer, EOS merge, real partition selection, and Azure final-report paths. Derive safe row and byte upper bounds from the actual incoming block, preserve cumulative growth for every sorter that can be touched, reserve cold dispatch copies conservatively, and use saturating arithmetic for all reservation totals. Add production-path tests for reservation transfer, terminal cleanup, merge fan-in, many-partition selection, and Azure provider cleanup.

### Release note

Harden Iceberg sorted-write memory admission for many-partition input and asynchronous writer lifecycle boundaries.

### Check List (For Author)

- Test: Unit Test
    - 29 focused ASAN BE tests passed across spill admission, async writer, Iceberg partition/table writers, Hive report lifecycle, sorter, and reservation transfer suites.
    - All affected production and test objects compiled successfully in the ASAN build.
    - All 12 affected C/C++ files passed clang-format 16.
    - Focused clang-tidy findings in the changed sorter code were fixed; full translation-unit analysis remains blocked by pre-existing unconditional static assertions in be/src/util/jni-util.h.
- Behavior changed: Yes. Memory admission now uses the actual input rows and bytes while retaining safe cumulative growth and cold-writer bounds.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66348

Problem Summary: Parallel regression suites can share an MTMV database. The getJobName helper queried mv_infos(), which materializes external metadata for every MV in that database, so an unrelated transient catalog failure could fail job lookup in another suite. Query MV job metadata directly and scope the lookup by both database and MV name.

### Release note

None

### Check List (For Author)

- Test: Unit Test

    - SuiteJobLookupTest verifies the isolated jobs metadata query.

    - Regression framework tests: 4 passed.

    - Framework Java and Groovy compilation passed.

- Behavior changed: No. Regression job lookup no longer evaluates unrelated MV status.

- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66348

Problem Summary: The Iceberg merge sink tests used a default mock runtime state after Iceberg writers began requiring coordinator acknowledgement of external-file reports. The inner table writer therefore rejected open before twelve tests reached the behavior they intended to verify. Use an ACK-capable mock runtime state for successful merge writer scenarios while preserving the fail-closed production check.

### Release note

None

### Check List (For Author)

- Test: Unit Test

    - Reproduced 12 failures in VIcebergMergeSinkTest before the fixture fix.

    - 15 focused ASAN tests passed after the fix, including the no-ACK rejection test.

    - The affected test source compiled with the ASAN BE test flags.

    - The affected C++ file passed clang-format 16.

- Behavior changed: No. This updates the test coordinator capability only.

- Does this need documentation: No
@Gabriel39
Gabriel39 force-pushed the fix/iceberg-write-safety branch from 4c63bf4 to 13cbc27 Compare August 6, 2026 15:16
@Gabriel39

Copy link
Copy Markdown
Contributor Author

run buildall

@Gabriel39

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: All Codex review accounts are usage-limited; earliest retry is 2026-08-08T03:32:00Z.
Workflow run: https://github.com/apache/doris/actions/runs/31115028759

Please trigger /review again after that time.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29480 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 13cbc27a21ad4ce130c42ce4f9fb7e9f1c76f408, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17920	4209	4187	4187
q2	2009	331	207	207
q3	10317	1435	807	807
q4	4680	476	344	344
q5	7488	952	562	562
q6	176	169	138	138
q7	761	803	614	614
q8	9357	1553	1538	1538
q9	5416	4066	4055	4055
q10	6797	1648	1358	1358
q11	502	369	334	334
q12	736	566	449	449
q13	18065	3303	2722	2722
q14	271	258	249	249
q15	q16	729	736	661	661
q17	977	1029	1009	1009
q18	6621	5658	5575	5575
q19	1169	1243	1098	1098
q20	795	694	578	578
q21	6183	2913	2664	2664
q22	477	382	331	331
Total cold run time: 101446 ms
Total hot run time: 29480 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5159	4696	4688	4688
q2	307	342	220	220
q3	5025	5275	4673	4673
q4	2223	2283	1448	1448
q5	4563	4608	4466	4466
q6	242	183	140	140
q7	1878	1708	1535	1535
q8	2407	2199	2117	2117
q9	7200	7032	6698	6698
q10	4239	4262	3814	3814
q11	547	405	370	370
q12	703	717	500	500
q13	2946	3264	2804	2804
q14	287	278	245	245
q15	q16	662	689	634	634
q17	1287	1241	1212	1212
q18	12176	11072	11813	11072
q19	2857	1087	1082	1082
q20	2218	2210	1930	1930
q21	5398	4664	4764	4664
q22	549	476	413	413
Total cold run time: 62873 ms
Total hot run time: 54725 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 166979 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 13cbc27a21ad4ce130c42ce4f9fb7e9f1c76f408, data reload: false

query5	4315	578	451	451
query6	459	230	208	208
query7	4900	554	331	331
query8	322	166	151	151
query9	8779	4091	4063	4063
query10	491	358	330	330
query11	5892	2194	2013	2013
query12	177	98	99	98
query13	1250	557	429	429
query14	6093	4351	3976	3976
query14_1	3840	3845	3814	3814
query15	200	194	173	173
query16	966	471	437	437
query17	911	667	562	562
query18	2443	469	346	346
query19	211	190	147	147
query20	104	102	105	102
query21	235	162	136	136
query22	13052	12992	12738	12738
query23	15717	15134	14696	14696
query23_1	14837	14726	14693	14693
query24	7656	1718	1267	1267
query24_1	1258	1285	1269	1269
query25	559	456	390	390
query26	1317	354	214	214
query27	2624	574	390	390
query28	4578	2037	2049	2037
query29	1070	639	506	506
query30	343	260	226	226
query31	1178	1129	1057	1057
query32	115	69	67	67
query33	533	350	239	239
query34	1195	1161	625	625
query35	728	761	635	635
query36	779	796	676	676
query37	159	106	90	90
query38	1824	1765	1689	1689
query39	815	814	794	794
query39_1	784	782	791	782
query40	260	166	143	143
query41	64	64	62	62
query42	94	93	95	93
query43	321	326	279	279
query44	1432	775	763	763
query45	193	175	172	172
query46	1051	1170	738	738
query47	1525	1534	1456	1456
query48	431	416	308	308
query49	577	410	309	309
query50	1084	441	351	351
query51	11080	10501	10334	10334
query52	88	88	76	76
query53	261	283	194	194
query54	284	233	223	223
query55	78	72	66	66
query56	300	314	285	285
query57	1018	1016	905	905
query58	280	258	251	251
query59	1584	1641	1400	1400
query60	314	264	266	264
query61	158	160	153	153
query62	400	322	276	276
query63	239	195	203	195
query64	2883	1028	848	848
query65	3895	3829	3839	3829
query66	1831	475	348	348
query67	28097	28130	27968	27968
query68	3281	1538	1078	1078
query69	409	305	265	265
query70	879	832	770	770
query71	355	340	300	300
query72	2982	2621	2360	2360
query73	916	806	428	428
query74	4636	4503	4301	4301
query75	2380	2353	2026	2026
query76	2324	1177	798	798
query77	358	380	291	291
query78	11115	11176	10632	10632
query79	1303	1099	746	746
query80	635	565	508	508
query81	461	331	288	288
query82	287	177	141	141
query83	334	324	297	297
query84	311	164	140	140
query85	997	691	651	651
query86	271	241	228	228
query87	1983	1946	1833	1833
query88	3718	2800	2858	2800
query89	376	314	280	280
query90	2115	196	191	191
query91	202	189	169	169
query92	62	61	55	55
query93	1648	1522	996	996
query94	564	359	326	326
query95	784	494	575	494
query96	1072	778	350	350
query97	2448	2497	2329	2329
query98	198	187	194	187
query99	731	724	612	612
Total cold run time: 252855 ms
Total hot run time: 166979 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 23.99 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 13cbc27a21ad4ce130c42ce4f9fb7e9f1c76f408, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.04	0.05
query3	0.26	0.14	0.13
query4	1.60	0.14	0.14
query5	0.25	0.24	0.23
query6	1.17	0.83	0.83
query7	0.04	0.01	0.01
query8	0.05	0.04	0.04
query9	0.37	0.30	0.31
query10	0.58	0.57	0.57
query11	0.18	0.13	0.15
query12	0.18	0.14	0.14
query13	0.46	0.46	0.47
query14	0.99	0.99	1.00
query15	0.60	0.58	0.58
query16	0.33	0.32	0.31
query17	1.10	1.05	1.08
query18	0.22	0.19	0.19
query19	2.11	2.00	2.00
query20	0.01	0.01	0.01
query21	15.44	0.23	0.13
query22	4.74	0.05	0.04
query23	16.11	0.31	0.13
query24	2.94	0.39	0.33
query25	0.11	0.04	0.05
query26	0.74	0.21	0.16
query27	0.04	0.04	0.04
query28	3.51	0.81	0.35
query29	12.52	3.98	3.22
query30	0.28	0.16	0.14
query31	2.78	0.55	0.33
query32	3.22	0.57	0.49
query33	3.10	3.18	3.17
query34	15.64	3.94	3.24
query35	3.21	3.24	3.26
query36	0.54	0.43	0.42
query37	0.09	0.06	0.06
query38	0.05	0.04	0.03
query39	0.03	0.03	0.03
query40	0.17	0.15	0.14
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 96.03 s
Total hot run time: 23.99 s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants